package cn.zhxu.crud;

import org.springframework.beans.BeanUtils;

public interface Copyer<T extends Copyer<T>> {

    @SuppressWarnings("all")
    default T copy() {
        try {
            var instance = getClass().getDeclaredConstructor().newInstance();
            BeanUtils.copyProperties(this, instance);
            return (T) instance;
        } catch (ReflectiveOperationException e) {
            throw new IllegalStateException(e);
        }
    }

}
